package data

import (
    "context"
    "time"

    "github.com/go-kratos/kratos/v2/log"
    "gorm.io/gorm"
    "mall/app/order/internal/biz"
    "mall/app/order/internal/domain"
)

type Order struct {
    Id        uint      `gorm:"primaryKey;type:int(10) unsigned AUTO_INCREMENT;comment:自增主键"`
    OrderNo   string    `gorm:"type:varchar(50) not null;default:'';comment:订单号"`
    Price     float64   `gorm:"type:decimal(12,2) unsigned not null;default:0;comment:商品总价"`
    CreatedAt time.Time `gorm:"type:datetime(0) not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
}

var _ biz.OrderRepo = (*orderRepo)(nil)

type orderRepo struct {
    data  *Data
    model *gorm.DB
    log   *log.Helper
}

func NewOrderRepo(data *Data, logger log.Logger) biz.OrderRepo {
    return &orderRepo{
        data:  data,
        model: data.db.Model(&Order{}),
        log:   log.NewHelper(log.With(logger, "module", "repo/order")),
    }
}

func (repo *orderRepo) Create(ctx context.Context, order *domain.Order) (*domain.Order, error) {
    // TODO implement me
    panic("implement me")
}

func (repo *orderRepo) List(ctx context.Context) ([]*domain.Order, error) {
    // TODO implement me
    panic("implement me")
}

func (repo *orderRepo) Detail(ctx context.Context, OrderNo string) (*domain.Order, error) {
    // TODO implement me
    panic("implement me")
}
